<template>
  <v-layout class="release-container" justify-start align-start wrap>
    <v-flex md12 text-xs-left>
      <v-btn flat round @click="$router.go(-1)">
        <ui-icon icon="angle-left fa-lg"></ui-icon>
        <div class="ml-2">返回</div>
      </v-btn>
    </v-flex>
    <v-flex md6 pt-4>
      <v-layout justify-start align-center wrap px-5>
        <v-flex md12 d-flex align-center justify-start>
          <v-flex md4>
            <span class="subTitle title-color">姓名</span>
          </v-flex>

          <v-flex md8>
            <v-text-field type="text" v-model="user.realName" solo></v-text-field>
          </v-flex>
        </v-flex>

        <v-flex md12 d-flex align-center justify-start>
          <v-flex md4>
            <span class="subTitle title-color">QQ</span>
          </v-flex>

          <v-flex md8>
            <v-text-field type="number" v-model="user.qqNumber" solo></v-text-field>
          </v-flex>
        </v-flex>

        <v-flex md12 d-flex align-center justify-start mt-3>
          <v-flex md4>
            <span class="subTitle title-color">手机号码</span>
          </v-flex>

          <v-flex md8>
            <v-text-field type="number" v-model="user.mobilePhone" solo></v-text-field>
          </v-flex>
        </v-flex>

        <v-flex md12 d-flex align-center justify-start mt-3>
          <v-flex md4>
            <span class="subTitle title-color">邮箱</span>
          </v-flex>

          <v-flex md8>
            <v-text-field type="text" v-model="user.email" solo></v-text-field>
          </v-flex>
        </v-flex>

        <!-- <v-flex md12 d-flex align-center justify-start mt-3>
          <v-flex md4>
            <span class="subTitle title-color">身份证号</span>
          </v-flex>

          <v-flex md8>
            <v-text-field type="password" v-model="user.password" solo></v-text-field>
          </v-flex>
        </v-flex> -->

        <v-flex md12 mt-4 d-flex align-center justify-center>
          <v-flex md4>
            <v-btn large round color="primary" @click="onSave">
              <span class="title">保存</span>
            </v-btn>
          </v-flex>
        </v-flex>
      </v-layout>
    </v-flex>
  </v-layout>
</template>


<script lang="ts">
// 使用类装饰器
import { Component, Vue } from "vue-property-decorator";
import { KV } from "@/utils/type";
import { Todo, Admin, Login, System } from "@/api";
import { AddUserVo, SysUserGroup, RequestPageVo, CustomUserLoginInfo, BlacklistInfo } from '@/api/bean';
import Cookie from 'js-cookie';
declare const $Vue: Vue;

@Component({})
export default class TopupAudit extends Vue {
  private roleTypes: Array<KV> = [
  ];

  private user: any = {
    
  };

  private type: string = "add";

  protected mounted() {
    // this.getRoleList()
    
    let params = this.$route.params;
    // this.type = this.$route.query.type;
    if (this.$route.query.type === "edit") {
      this.user = params;
    }
  }

  private validate(): boolean {
    let pass = true;
    
    return pass;
  }

  /**
   * 保存用户设置
   */
  private onSave() {
    if (this.validate()) {
      if (this.type === "add") {
        this.addBlack();
      } else {
        this.modifyUser();
      }
    }
  }

  /**
   * 处理角色列表
   */
  private handleRoleList(data: any) {
    let list: any = [];
    data.forEach((item: any) => {
      list.push({
        value: item.groupId,
        text: item.groupName,
        sysGroup: item.sysGroup,
      });
    });
    this.roleTypes = list;
  }

  private async addBlack() {

    const params: BlacklistInfo = {
      mobilePhone: this.user.mobilePhone,
      qqNumber: this.user.qqNumber,
      realName: this.user.realName,
      createUserId: Number(Cookie.get('userId')),
      email: this.user.email,
    };
    console.log(params);
    
    const { data } = await System.saveBlackUser.r(params);
    console.log("addBlack", data);
    $Vue.$emit("snackbar", {
      message: data.message
    });
    if (data.result === 0) {
      this.$router.go(-1);
    } else {
    }
  }

  private async modifyUser() {
    // const params: SysUserGroup = {

    // };
    // const { data } = await Admin.modifyUser.r(params);
    // console.log("buyerAudit", data);
    // if (data.result === 0) {
    // } else {
    //   $Vue.$emit("snackbar", data.message);
    // }
  }

}
</script>

<style lang="less" scoped>
</style>


